package com.shop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.pojo.sms.Sms_Home_Subject_Spu;
import com.shop.service.Sms_Home_Subject_Spu_Service;
import com.shop.utils.LayuiUtils;
import com.shop.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 后台专题列表关联的专题商品-李贝贝
 */
@RestController
@RequestMapping("/home_subject_spu")
public class Sms_Home_Subject_Spu_Controller {

    @Autowired
    private Sms_Home_Subject_Spu_Service sms_home_subject_spu_service;

    /**
     * 后台显示所有专题列表关联的专题商品
     * @param page
     * @param limit
     * @param sms_home_subject_spu
     * @return
     */
    @GetMapping("/find_Admin_Sms_Home_Subject_Spu")
    public LayuiUtils<Sms_Home_Subject_Spu> find_Admin_Sms_Home_Subject_Spu(Integer page, Integer limit,Sms_Home_Subject_Spu sms_home_subject_spu){
        Page<Sms_Home_Subject_Spu> pages = new Page<>(page,limit);
        return sms_home_subject_spu_service.find_admin_sms_home_subject_spu(pages,sms_home_subject_spu);
    }

    /**
     * 后台添加专题列表关联的专题商品
     * @param sms_home_subject_spu
     * @return
     */
    @PostMapping("/insert_Sms_Home_Subject_Spu")
    public R insert_Sms_Home_Subject_Spu(Sms_Home_Subject_Spu sms_home_subject_spu){
        System.out.println(sms_home_subject_spu);
        return sms_home_subject_spu_service.insert_sms_home_subject_spu(sms_home_subject_spu);
    }

    /**
     * 后台删除专题列表关联的专题商品
     * @param id
     * @return
     */
    @DeleteMapping("/delete_Sms_Home_Subject_Spu")
    public R delete_Sms_Home_Subject_Spu(@RequestParam List<Long> id){
        return sms_home_subject_spu_service.delete_sms_home_subject_spu(id);
    }

    /**
     * 后台修改专题列表关联的专题商品
     * @param sms_home_subject_spu
     * @return
     */
    @PutMapping("/update_Sms_Home_Subject_Spu")
    public R update_Sms_Home_Subject_Spu(Sms_Home_Subject_Spu sms_home_subject_spu){
        return sms_home_subject_spu_service.update_sms_home_subject_spu(sms_home_subject_spu);
    }
}
